Skip to content

获取软件更新状态 - GetSoftUpdateStatus

函数简介

获取客户端软件更新状态,并返回最新版本业务信息。

本接口只负责查询。若要下载并安装/覆盖,请调用 SoftUpdateStart(见 软件自更新模块总览)。不要再寻找名为 SoftUpdateCheck 的接口——已移除,避免与本接口重复。

返回数据格式:

json
{
  "Code": 1,
  "Message": "",
  "CurrentVersion": "1.0.0",
  "LatestVersion": "1.1.0",
  "HasUpdate": true,
  "SoftVersion": {
    "SoftCode": "demo-soft",
    "VersionNumber": "1.1.0",
    "VersionName": "2026春季版",
    "VersionType": 1,
    "FileName": "demo-installer.exe",
    "FileSize": 12345678,
    "FileMd5": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "FileUrl": "https://example.com/demo-installer.exe",
    "IsForceUpdate": false,
    "UpdateContent": "修复已知问题并优化稳定性",
    "ReleaseDate": "2026-04-24 09:00:00",
    "IsLatest": true
  }
}
字段名类型说明
Code整数结果状态码,通常 1 表示成功,0 或其他值表示失败。
Message字符串提示信息或错误信息;失败时多为 错误码:中文描述(如 "2003:参数无效")。成功时可能为 success。完整对照见 客户端错误码说明
CurrentVersion字符串当前版本号。
LatestVersion字符串最新版本号。
HasUpdate布尔是否存在可更新版本。
SoftVersion对象版本对象信息。

常见错误码(Message 字段)

Message含义
2003:参数无效参数无效
2004:用户不存在用户不存在
2005:软件不可用或未开通软件不可用或未开通

SoftVersion 字段说明:

字段名类型说明
SoftCode字符串软件编码。
VersionNumber字符串版本号。
VersionName字符串版本名称。
VersionType整数版本类型编码。
FileName字符串安装包文件名。
FileSize整数安装包大小(字节)。
FileMd5字符串安装包 MD5 校验值。
FileUrl字符串安装包下载地址。
IsForceUpdate布尔是否强制更新。
UpdateContent字符串更新说明内容。
ReleaseDate字符串版本发布时间。
IsLatest布尔是否为最新版本。

接口名称

GetSoftUpdateStatus

DLL调用

long GetSoftUpdateStatus(string userCode, string softCode, string softVersion, string dealerCode);

参数说明

参数名类型说明
userCode字符串用户码。
softCode字符串软件码。
softVersion字符串软件版本。
dealerCode字符串经销商码。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
OlaAuthSoftUpdateStatusReturn result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode");
// result.Code == 1 表示成功
csharp
using OLAPlug;

var ola = new OLAPlugServer();
OlaAuthSoftUpdateStatusReturn result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode");
// result.Code == 1 表示成功
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
json_result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode")
# Python SDK 返回 JSON 字符串,需自行解析
java
import com.olaplug.OLAPlugServer;
import com.olaplug.model.OlaAuthSoftUpdateStatusReturn;

OLAPlugServer ola = new OLAPlugServer();
OlaAuthSoftUpdateStatusReturn result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode");
// result.Code == 1 表示成功
go
import "github.com/ola/olaplug/olaplug"

ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
result := ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode")
// result.Code == 1 表示成功
rust
use olaplug::OLAPlugServer;

let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let result = ola.get_soft_update_status("userCode", "softCode", "1.0.0", "dealerCode");
// result.code == 1 表示成功
cpp
var ola = com("OlaPlug.OlaSoft")
var result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode")
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
Set result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode")
text
.局部变量 ola, OLAPlug
.局部变量 result, OlaAuthSoftUpdateStatusReturn
ola.创建 ()
result = ola.GetSoftUpdateStatus(“userCode”, “softCode”, “1.0.0”, “dealerCode”)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var json = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode");
// Aardio SDK 返回 JSON 字符串,需自行解析
text
变量 ola <类型 = OLAPlugServer>
变量 result <类型 = OlaAuthSoftUpdateStatusReturn>
ola = 新建 OLAPlugServer
result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode")
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
OlaAuthSoftUpdateStatusReturn result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode");
// result.Code == 1 表示成功

原生 DLL 调用

cpp
long ptr = GetSoftUpdateStatus(instance, "userCode", "softCode", "1.0.0", "dealerCode");
if (ptr != 0) {
    char buffer[512] = {0};
    GetStringFromPtr(ptr, buffer, sizeof(buffer));
    FreeStringPtr(ptr);
}
csharp
using System.Runtime.InteropServices;
using System.Text;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long GetSoftUpdateStatus(string userCode, string softCode, string softVersion, string dealerCode);

long ptr = GetSoftUpdateStatus(instance, "userCode", "softCode", "1.0.0", "dealerCode");
if (ptr != 0) {
    StringBuilder sb = new StringBuilder(GetStringSize(ptr) + 1);
    GetStringFromPtr(ptr, sb, sb.Capacity);
    FreeStringPtr(ptr);
    string result = sb.ToString();
}
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ptr = ola.GetSoftUpdateStatus(instance, "userCode", "softCode", "1.0.0", "dealerCode")
if ptr:
    buf = create_string_buffer(512)
    ola.GetStringFromPtr(ptr, buf, 512)
    ola.FreeStringPtr(ptr)
    result = buf.value.decode("utf-8")

返回值

调用方式返回值说明
SDKOlaAuthSoftUpdateStatusReturn结构化返回对象;Code == 1 表示成功
原生 DLL非 0成功,返回 JSON 字符串格式的结果。
原生 DLL0失败。

注意事项

项目说明
释放内存返回的字符串指针需要调用 FreeStringPtr 接口释放内存。
HasUpdate 可直接用于判断是否提示更新HasUpdate 可直接用于判断是否提示更新。
历史更新说明需要展示多版本更新日志时,请使用 GetSoftUpdateLogs